# Override the versioning methods to have the version name
# suffixed to the filename instead of prefixed
module CarrierWave
  module Uploader
    module Versions
      def full_filename(for_file)
        parent_name = super(for_file)
        ext         = File.extname(parent_name)
        base_name   = parent_name.chomp(ext)
        [base_name, version_name].compact.join('_') + ext
      end

      def full_original_filename
        parent_name = super
        ext         = File.extname(parent_name)
        base_name   = parent_name.chomp(ext)
        [base_name, version_name].compact.join('_') + ext
      end
    end
  end
end

CarrierWave.configure do |config|
  config.fog_credentials = {
    provider: "AWS",
    aws_access_key_id: "AKIAIAYM6VIGTEHMEX2Q",
    aws_secret_access_key: "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"
  }
  if Rails.env.development?
    config.fog_directory = "mpztestwebcom"
  else
    config.fog_directory = "speakmirrorcom"
  end
end

